package org.openspml.providers.one_c.api.users;

import java.util.AbstractList;

import com.jacob.com.Dispatch;

/**
 * @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
 * @version $Id$
 */
class InfoBaseUserList extends AbstractList<InfoBaseUser> {
	private final Dispatch array;
	
	public InfoBaseUserList(Dispatch dispatch) {
		this.array = dispatch;
	}
	
	@Override
	public InfoBaseUser get(int index) {
		if ((index < 0) || (index >= size())) {
			throw new IllegalArgumentException("Index [" + index + "] out of bounds");
		}
		
		return new InfoBaseUser(Dispatch.call(array, "Get", index).toDispatch());
	}

	@Override
	public int size() {
		return Dispatch.call(array, "Count").getInt();
	}
}
